home *** CD-ROM | disk | FTP | other *** search
- property oldcomposerect
- global lightImage, offscreenBuffer, composerect, composewidth, composeheight
-
- on lightinit
- lightImage = image(composewidth, composeheight, 32)
- lightImage.fill(0, 0, composewidth, composeheight, rgb(0, 0, 0))
- offscreenBuffer = image(composewidth, composeheight, 32)
- offscreenBuffer.fill(0, 0, composewidth, composeheight, rgb(0, 0, 0))
- end
-
- on lightray Img, hdis, vdis
- hdis = hdis - 127
- vdis = vdis - 127
- currentImage = Img.duplicate()
- if (lightImage.ilk <> #image) or (offscreenBuffer.ilk <> #image) then
- lightinit()
- end if
- lightImage.copyPixels(currentImage, lightImage.rect, lightImage.rect, [#blendLevel: 255])
- offscreenBuffer.copyPixels(lightImage, offscreenBuffer.rect, offscreenBuffer.rect, [#blendLevel: 255])
- repeat with i = 1 to 12
- per = i / 30.0
- per2 = 1 - ((i - 1) / 12.0)
- offscreenBuffer.copyPixels(lightImage, rect(0 - (i * 10) + (hdis * per), 0 - (i * 10) + (vdis * per), Img.width + (i * 10) + (hdis * per), Img.height + (i * 10) + (vdis * per)), offscreenBuffer.rect, [#blendLevel: 255 * per2])
- end repeat
- currentImage.copyPixels(offscreenBuffer, currentImage.rect, offscreenBuffer.rect)
- if oldcomposerect <> composerect then
- lightinit()
- oldcomposerect = composerect
- end if
- return currentImage
- end
-
- on lightray2 Img, hdis, vdis
- hdis = hdis - 127
- vdis = vdis - 127
- currentImage = Img.duplicate()
- if (lightImage.ilk <> #image) or (offscreenBuffer.ilk <> #image) then
- lightinit()
- end if
- lightImage.copyPixels(blurr(currentImage), lightImage.rect, lightImage.rect, [#blendLevel: 255])
- offscreenBuffer.copyPixels(lightImage, offscreenBuffer.rect, offscreenBuffer.rect, [#blendLevel: 255])
- repeat with i = 1 to 12
- per = i / 30.0
- per2 = 1 - ((i - 1) / 12.0)
- offscreenBuffer.copyPixels(lightImage, rect(0 - (i * 10) + (hdis * per), 0 - (i * 10) + (vdis * per), Img.width + (i * 10) + (hdis * per), Img.height + (i * 10) + (vdis * per)), offscreenBuffer.rect, [#blendLevel: 255 * per2])
- end repeat
- currentImage.copyPixels(offscreenBuffer, currentImage.rect, offscreenBuffer.rect)
- if oldcomposerect <> composerect then
- lightinit()
- oldcomposerect = composerect
- end if
- return currentImage
- end
-